package com.menglei.dailytasks.broadcast;

import android.app.Service;
import android.content.Intent;
import android.nfc.Tag;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;

import androidx.annotation.Nullable;

public class BindService extends Service {
    private static final String TAG = "BindService";
    private MyBinder binder = new MyBinder();

    public class MyBinder extends Binder {
        public void PlayMusic() {
            Toast.makeText(getApplicationContext(), "播放音乐", Toast.LENGTH_SHORT).show();
        }

        public void PauseMusic() {
            Toast.makeText(getApplicationContext(), "暂停音乐", Toast.LENGTH_SHORT).show();
        }

    }


    @Override
    public void onCreate() {
        Log.i(TAG, "onCreate");
        super.onCreate();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.i(TAG, "onStartCommand");
        return super.onStartCommand(intent, flags, startId);
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        Log.i(TAG, "onBind");
        return binder;
    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.i(TAG, "onUnbind");
        return super.onUnbind(intent);
    }

    @Override
    public void onDestroy() {
        Log.i(TAG, "onDestroy");
        super.onDestroy();
    }
}
